<template>
  <div class="home">
    <div class="content">
      <!-- 头部 -->
      <header>
        <div class="icon-location-box">
          <div class="icon-location"></div>
        </div>
        <p>沈阳市规划大厦</p>
        <i class="fa fa-caret-down" aria-hidden="true"></i>
      </header>
      <!-- 搜索部分 -->
      <div class="search-box">
        <div class="search" ref="search">
          <!-- 输入框白色部分 -->
          <div class="search-content">
            <i class="fa fa-search"></i>
            搜索饿了么商家、商品名称
          </div>
        </div>
      </div>
      <!-- 点餐部分 -->
      <ul class="orderlist">
        <li @click="tobusinesslist(1)">
          <img src="../assets/dcfl01.png" />
          <p>美食</p>
        </li>
        <li @click="tobusinesslist(2)">
          <img src="../assets/dcfl02.png" />
          <p>早餐</p>
        </li>
        <li @click="tobusinesslist(3)">
          <img src="../assets/dcfl03.png" />
          <p>跑腿代购</p>
        </li>
        <li @click="tobusinesslist(4)">
          <img src="../assets/dcfl04.png" />
          <p>汉堡披萨</p>
        </li>
        <li @click="tobusinesslist(5)">
          <img src="../assets/dcfl05.png" />
          <p>甜品饮品</p>
        </li>
        <li @click="tobusinesslist(6)">
          <img src="../assets/dcfl06.png" />
          <p>速食简餐</p>
        </li>
        <li @click="tobusinesslist(7)">
          <img src="../assets/dcfl07.png" />
          <p>地方小吃</p>
        </li>
        <li @click="tobusinesslist(8)">
          <img src="../assets/dcfl08.png" />
          <p>米粉面馆</p>
        </li>
        <li @click="tobusinesslist(9)">
          <img src="../assets/dcfl09.png" />
          <p>包子粥铺</p>
        </li>
        <li @click="tobusinesslist(10)">
          <img src="../assets/dcfl10.png" />
          <p>炸鸡炸串</p>
        </li>
      </ul>
      <!-- 横幅广告 -->
      <div class="banner">
        <h3>品质套餐</h3>
        <p>搭配齐全吃的好</p>
        <a href="">立即抢购&gt;</a>
      </div>
      <!-- 超级会员 -->
      <div class="super-member">
        <div class="super-member-left">
          <img src="../assets/super_member.png" alt="" />
          <h3>超级会员</h3>
          <p>&#8226; 每月享超值权益</p>
        </div>

        <div class="super-member-right">
          <a href="">立即开通&gt;</a>
        </div>
      </div>
      <!-- 推荐商家 -->
      <div class="recommend">
        <div></div>
        <p>推荐商家</p>
        <div></div>
      </div>
      <!-- 推荐方式 -->
      <ul class="recommend-type">
        <li>
          综合排序
          <i class="fa fa-caret-down" aria-hidden="true"></i>
        </li>
        <li>距离最近</li>
        <li>销量最高</li>
        <li>筛选<i class="fa fa-filter"></i></li>
      </ul>

      <!-- 商家列表 -->
      <ul class="business-list">
        <li>
          <img src="../assets/sj01.png" alt="" />
          <div class="business-info">
            <div class="business-title">
              <h3>万家饺子（软件园E18店）</h3>
              <div class="square">&#8226;</div>
            </div>
            <div class="business-star">
              <div class="business-star-left">
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <p>4.9 月售345单</p>
              </div>
              <div class="business-star-right">蜂鸟专送</div>
            </div>
            <div class="business-deliveryfee">
              <p>&#165;15起送 | &#165;3配送</p>
              <p>3.22km | 30分钟</p>
            </div>
            <div class="business-explain">
              <div>各种饺子</div>
            </div>
            <div class="business-promotion">
              <div class="business-promotion-left">
                <div>新</div>
                <p>饿了么新用户首单立减9元</p>
              </div>
              <div class="business-promotion-right">
                <p>2个活动</p>
                <i class="fa fa-caret-down"></i>
              </div>
            </div>
            <div class="business-specialoffer">
              <div class="business-specialoffer-left">
                <div>特</div>
                <p>特价商品5元起</p>
              </div>
            </div>
          </div>
        </li>
        <li>
          <img src="../assets/sj02.png" alt="" />
          <div class="business-info">
            <div class="business-title">
              <h3>小锅饭豆腐馆（全运店）</h3>
              <div class="square">&#8226;</div>
            </div>
            <div class="business-star">
              <div class="business-star-left">
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <p>4.9 月售345单</p>
              </div>
              <div class="business-star-right">蜂鸟专送</div>
            </div>
            <div class="business-deliveryfee">
              <p>&#165;15起送 | &#165;3配送</p>
              <p>3.22km | 30分钟</p>
            </div>
            <div class="business-explain">
              <div>各种饺子</div>
            </div>
            <div class="business-promotion">
              <div class="business-promotion-left">
                <div>新</div>
                <p>饿了么新用户首单立减9元</p>
              </div>
              <div class="business-promotion-right">
                <p>2个活动</p>
                <i class="fa fa-caret-down"></i>
              </div>
            </div>
            <div class="business-specialoffer">
              <div class="business-specialoffer-left">
                <div>特</div>
                <p>特价商品5元起</p>
              </div>
            </div>
          </div>
        </li>
        <li>
          <img src="../assets/sj03.png" alt="" />
          <div class="business-info">
            <div class="business-title">
              <h3>麦当劳麦乐送（全运路店）</h3>
              <div class="square">&#8226;</div>
            </div>
            <div class="business-star">
              <div class="business-star-left">
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <p>4.9 月售345单</p>
              </div>
              <div class="business-star-right">蜂鸟专送</div>
            </div>
            <div class="business-deliveryfee">
              <p>&#165;15起送 | &#165;3配送</p>
              <p>3.22km | 30分钟</p>
            </div>
            <div class="business-explain">
              <div>各种饺子</div>
            </div>
            <div class="business-promotion">
              <div class="business-promotion-left">
                <div>新</div>
                <p>饿了么新用户首单立减9元</p>
              </div>
              <div class="business-promotion-right">
                <p>2个活动</p>
                <i class="fa fa-caret-down"></i>
              </div>
            </div>
            <div class="business-specialoffer">
              <div class="business-specialoffer-left">
                <div>特</div>
                <p>特价商品5元起</p>
              </div>
            </div>
          </div>
        </li>
        <li>
          <img src="../assets/sj04.png" alt="" />
          <div class="business-info">
            <div class="business-title">
              <h3>米村拌饭（浑南店）</h3>
              <div class="square">&#8226;</div>
            </div>
            <div class="business-star">
              <div class="business-star-left">
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <p>4.9 月售345单</p>
              </div>
              <div class="business-star-right">蜂鸟专送</div>
            </div>
            <div class="business-deliveryfee">
              <p>&#165;15起送 | &#165;3配送</p>
              <p>3.22km | 30分钟</p>
            </div>
            <div class="business-explain">
              <div>各种饺子</div>
            </div>
            <div class="business-promotion">
              <div class="business-promotion-left">
                <div>新</div>
                <p>饿了么新用户首单立减9元</p>
              </div>
              <div class="business-promotion-right">
                <p>2个活动</p>
                <i class="fa fa-caret-down"></i>
              </div>
            </div>
            <div class="business-specialoffer">
              <div class="business-specialoffer-left">
                <div>特</div>
                <p>特价商品5元起</p>
              </div>
            </div>
          </div>
        </li>
        <li>
          <img src="../assets/sj05.png" alt="" />
          <div class="business-info">
            <div class="business-title">
              <h3>申记串道（中海康城店）</h3>
              <div class="square">&#8226;</div>
            </div>
            <div class="business-star">
              <div class="business-star-left">
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <i class="fa fa-star"></i>
                <p>4.9 月售345单</p>
              </div>
              <div class="business-star-right">蜂鸟专送</div>
            </div>
            <div class="business-deliveryfee">
              <p>&#165;15起送 | &#165;3配送</p>
              <p>3.22km | 30分钟</p>
            </div>
            <div class="business-explain">
              <div>各种饺子</div>
            </div>
          </div>
        </li>
      </ul>
      <div class="footer-top"></div>
      <Footer></Footer>
    </div>
  </div>
</template>

<script>
import Footer from "../components/Footer";

export default {
  name: "Home",
  methods: {
    tobusinesslist(orderTypeId) {
      this.$router.push({path:'/businesslist',query:{orderTypeId:orderTypeId}});
    },
  },
  mounted() {
    let search = this.$refs.search;
    window.onscroll = ()=> {
      
      //获取距离top的滚动长度，当不符合对应客户端时，值为0
      let pctop = document.documentElement.scrollTop; //pc
      let moblietop = document.body.scrollTop; //移动端
      //获取当前视口宽度
      let clientWidth = document.documentElement.clientWidth;

      if (pctop == 0) {
        //证明是移动端
        if (moblietop >= clientWidth * 0.12) {
          //设置固定定位
          search.style.position = "fixed";
          search.style.left = "0px";
          search.style.top = "0px";
        } else {
          //改回普通定位
          search.style.position = "static";
        }
      } else if (moblietop == 0) {
        //证明是pc端
        if (pctop >= clientWidth * 0.12) {
          //设置固定定位
          search.style.position = "fixed";
          search.style.left = "0px";
          search.style.top = "0px";
        } else {
          //改回普通定位
          search.style.position = "static";
        }
      }
    };
  },
  destroyed(){
    window.onscroll= null;
  },
  components: {
    Footer,
  },
};
</script>

<style scoped>
/* 总容器 */
.content {
  width: 100%;
  height: 100%;
}
/* 头部 */
.content header {
  width: 100%;
  height: 12vw;
  background-color: #0097ff;
  display: flex;
  align-items: center;
}
.content header p {
  font-size: 4.5vw;
  font-weight: 700;
  color: #fff;
}
.content header i {
  color: #fff;
  margin-left: 1vw;
  font-size: 4vw;
}
/* 搜索框 */
.content .search-box {
  width: 100%;
  height: 13vw;
}
.content .search-box .search {
  width: 100%;
  height: 13vw;
  background-color: #0097ff;
  display: flex;
  justify-content: center;
  align-items: center;
}
.content .search-box .search .search-content {
  width: 90%;
  height: 9vw;
  background-color: #fff;
  border-radius: 2px;
  font-size: 3.5vw;
  font-family: "宋体";
  color: #aeaeae;
  text-align: center;
  line-height: 9vw;
  user-select: none; /* 区域文本不可选 */
}
/* 点餐部分 */
.content .orderlist {
  width: 100%;
  height: 48vw;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  align-content: center;
}
.content .orderlist li {
  width: 18vw;
  height: 20vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.content .orderlist li img {
  width: 12vw;
  height: 12vw;
  user-select: none;
}
.content .orderlist li p {
  font-size: 3.2vw;
  color: #666;
  user-select: none;
}
/* 横幅广告 */
.content .banner {
  width: 95%;
  height: 29vw;
  background-image: url(../assets/index_banner.png);
  background-repeat: no-repeat;
  background-size: cover;
  margin-left: 2.5vw;
}
.content .banner h3 {
  padding: 2vw 6vw 1vw 6vw;
  font-size: 4.2vw;
}
.content .banner p {
  padding: 0 6vw;
  font-size: 3.4vw;
  color: #666;
  margin-bottom: 3vw;
}
.content .banner a {
  padding: 0 6vw;
  font-size: 3vw;
  color: #c79060;
  font-weight: 700;
}
/* 超级会员 */
.content .super-member {
  width: 95%;
  height: 11.5vw;
  margin-left: 2.5vw;
  background-color: #feedc1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #644f1b;
  margin-top: 1.3vw;
  border-radius: 4px;
}
.content .super-member .super-member-left {
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.content .super-member .super-member-left img {
  width: 6vw;
  height: 6vw;
  margin: 0 2vw 0 4vw;
}
.content .super-member .super-member-left h3 {
  font-size: 4vw;
}
.content .super-member .super-member-left p {
  margin-left: 2vw;
  font-size: 3vw;
}
.content .super-member .super-member-right a {
  font-size: 3vw;
  margin-right: 4vw;
  color: #644f1b;
}
/* 推荐商家 */
.content .recommend {
  width: 100%;
  height: 14vw;
  display: flex;
  justify-content: center;
  align-items: center;
}
.content .recommend div {
  width: 6vw;
  height: 0.2vw;
  background-color: #888;
}
.content .recommend p {
  margin: 0 4vw 0 4vw;
  font-size: 4vw;
}
/* 推荐方式 */
.content .recommend-type {
  width: 100%;
  height: 5vw;

  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-bottom: 5vw;
}
.content .recommend-type li {
  font-size: 3.5vw;
  color: #555;
}
/* 商家列表 */
.content .business-list {
  width: 100%;
  /* margin-bottom: 14vw; */
}
.content .business-list li {
  width: 100%;
  box-sizing: border-box;
  padding: 2.5vw;

  display: flex;
  border-bottom: 1px solid #ddd;
}
.content .business-list li img {
  width: 18vw;
  height: 18vw;
}
.content .business-list li .business-info {
  padding-left: 2.5vw;
  width: 100%;
}
.content .business-list li .business-info .business-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2vw;
}
.content .business-list li .business-info .business-title h3 {
  font-size: 4vw;
  color: #333;
}
.content .business-list li .business-info .business-title .square {
  margin-right: 4vw;
}
.content .business-list li .business-info .business-star {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 3.1vw;
  margin-bottom: 2vw;
}
.content .business-list li .business-info .business-star .business-star-left {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.content .business-list li .business-info .business-star .business-star-left i {
  color: #fec80e;
  margin-right: 0.5vw;
}
.content .business-list li .business-info .business-star .business-star-left p {
  margin-left: 1vw;
  color: #666;
}
.content .business-list li .business-info .business-star .business-star-right {
  padding: 0 0.6vw;
  background-color: #0097ff;
  color: #fff;
  border-radius: 2px;
}
.content .business-list li .business-info .business-deliveryfee {
  font-size: 3.1vw;
  color: #666;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2vw;
}
.content .business-list li .business-info .business-explain {
  margin-bottom: 3vw;
}
.content .business-list li .business-info .business-explain div {
  display: inline;
  border: 1px solid #ddd;
  font-size: 2.8vw;
  color: #666;
  border-radius: 2px;
}
.content .business-list li .business-info .business-promotion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.8vw;
}
.content
  .business-list
  li
  .business-info
  .business-promotion
  .business-promotion-left {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.content
  .business-list
  li
  .business-info
  .business-promotion
  .business-promotion-left
  div {
  background-color: #70bc46;
  font-size: 3vw;
  color: #fff;
  border-radius: 3px;
  width: 4vw;
  height: 4vw;
  text-align: center;
  margin-right: 2vw;
}
.content
  .business-list
  li
  .business-info
  .business-promotion
  .business-promotion-left
  p {
  font-size: 3vw;
  color: #666;
}
.content
  .business-list
  li
  .business-info
  .business-promotion
  .business-promotion-right {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 2.5vw;
  color: #999;
}
.content
  .business-list
  li
  .business-info
  .business-promotion
  .business-promotion-right
  i {
  padding-left: 2vw;
}
.content .business-list li .business-info .business-specialoffer {
  margin-bottom: 1.8vw;
}
.content
  .business-list
  li
  .business-info
  .business-specialoffer
  .business-specialoffer-left {
  display: flex;
  align-items: center;
}
.content
  .business-list
  li
  .business-info
  .business-specialoffer
  .business-specialoffer-left
  div {
  background-color: #f1884f;
  font-size: 3vw;
  color: #fff;
  border-radius: 3px;
  width: 4vw;
  height: 4vw;
  text-align: center;
  margin-right: 2vw;
}
.content
  .business-list
  li
  .business-info
  .business-specialoffer
  .business-specialoffer-left
  p {
  font-size: 3vw;
  color: #666;
}
</style>
